/**
 * @param {string} s
 * @param {string} p
 * @return {boolean}
 */

// 未通过
var isMatch = function (s, p) {
  let si = 0;
  let pi = 0;
  let sys = null;
  while (si < s.length && pi < p.length) {
    const pt = p[pi];
    const st = s[si];
    if (p[pi + 1] === '*') {
      if (sys === '.') {

      } else {
        let pNum = 0;
        let sOld = si;
        for (let i = pi;p.length > i; i += 2) {
          if (p[i + 1] !== '*')
        }
        pi += 2
        while (p.length > pi) {
          if (p[pi + 1] === '*') {
            if (p[pi + 2] === pt) pi += 2
            else break
          } else if (pt === p[pi]) pi++
          else break
        }
        while (pt === s[pi]) {
          si++
        }
        if (si - sOld < pNum) {
          return false
        }
      }
    } else if (is(pt, st)) {
      si++
      pi++
    } else {
      return false
    }
  }
  if (pi !== p.length || si !== s.length) {
    return false
  }
  return true
};

function is(s1, s2) {
  return s1 === s2 || s1 === '.'
}

s = "daaaad", p = "da*d"

console.log(isMatch(s, p));


ddd
a*c*ddd

ddabdcdsdsdd
dd.*dd

ddadd
dda*aadd


ddaaaaadd
dda*b*aadd